
DEFINE VARIABLE vdate AS DATE.

/*                                        */
/*                                        */
/* DEFINE TEMP-TABLE td                   */
/*     FIELDS tddate AS DATE.             */
/*                                        */
/* INPUT FROM D:\p\dt.txt.                */
/* REPEAT:                                */
/*     CREATE td.                         */
/*     IMPORT td.                         */
/* END.                                   */
/* INPUT CLOSE.                           */
/*                                        */
/* FOR EACH td NO-LOCK WHERE tddate <> ?. */
/* /*     DISPLAY td.  */                 */
/*     RUN hkR1011q1(INPUT tddate) .      */
/* END.                                   */
/*                                        */

/* RUN hkr1011q1(INPUT TODAY). */



 
    IF CAN-FIND (first code_mstr NO-LOCK where code_fldname = "HKR1011A" and code_value = "lastrunQ") THEN DO:
        for first code_mstr exclusive-lock where code_fldname = "HKR1011A" and code_value = "lastrunQ" :
           assign code_cmmt    = STRING (today,"9999-99-99")  + " " + string(time,"HH:MM:SS")
                  code_user1 = "running..."
                  NO-ERROR .
        END.
    END.
    else  do:
        create code_mstr.
        assign code_fldname = "HKR1011A"
               code_value   = "lastrunQ"
               code_cmmt    = STRING (today,"9999-99-99")  + " " + string(time,"HH:MM:SS")
               code_user1 = "running..."
               NO-ERROR.
    end.
 

FOR EACH code_mstr NO-LOCK WHERE  code_fldname = "HKR1011A":
    if code_value = "Date" then do:
        if code_cmmt = ? or code_cmmt = "today" or code_cmmt = "" then do:
            assign vdate = today.
        end.
        else do:
            assign vdate  = date(code_cmmt) .
        end.
    end.
END.
 
RUN hkr1011q1(INPUT vdate).

quit.
